package com.zl.pro.service.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import com.zl.pro.mapper.OrderDetailsMapper;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zl.pro.mapper.OrderMapper;
import com.zl.pro.pojo.Order;
import com.zl.pro.pojo.OrderDetails;
import com.zl.pro.pojo.OrderPaging;
import com.zl.pro.service.OrderService;
@Service
public class OrderServiceImpl implements OrderService {
	
	@Autowired
	private OrderMapper orderMapper;
	@Autowired
	OrderDetailsMapper orderDetailsMapper;

	@Override
	public void addOrder(Order order) {
	  orderMapper.addOrder(order);

	}

	@Override
	public Long findMaxId() {
		
		return orderMapper.findMaxId();
	}

	@Override
	public void addOrderDetails(OrderDetails orderDetails) {
	   orderDetailsMapper.addOrderDetails(orderDetails);

	}

	//根据id查询订单详情
	@Override
	public List<Order> orderListByid(OrderPaging page) {
		if(page.getPage()==null) {
			page.setPage(1);
		}
		return orderMapper.orderListByid(page);
	}

	@Override
	public Integer orderListByidCount(OrderPaging page) {
		
		return orderMapper.orderListByidCount(page);
	}

	@Override
	public List<Order> seAllOrder(OrderPaging page) {
		
		if(page.getPage()==null) {
			page.setPage(1);
		}
		return orderMapper.seAllOrder(page);
	}

	@Override
	public Integer seAllOrderCount(OrderPaging page) {
		
		return orderMapper.seAllOrderCount(page);
	}

	@Override
	public List<Order> findTime() {
		// TODO Auto-generated method stub
		return orderMapper.findTime();
	}

	//管理员确认订单
	@Override
	public void updateOrderAdmin(String orderid, String adminoperating) {
		// TODO Auto-generated method stub
		orderMapper.updateOrderAdmin(orderid, adminoperating);
		
	}

	@Override
	public List<Order> findOrderId(Date date1, Date date2) {
		// TODO Auto-generated method stub
		return orderMapper.findOrderId(date1, date2);
	}
	
	//根据订单号orderid查询订单详情
	@Override
	public OrderDetails findOrderDetails(String orderid) {
		// TODO Auto-generated method stub
		return orderDetailsMapper.findOrderDetails(orderid);
	}
	//根据订单号修改订单详情信息
	@Override
	public void updateOrderDetails(String orderid, BigDecimal fundunitprice, BigDecimal fundnum) {
		// TODO Auto-generated method stub
		orderDetailsMapper.updateOrderDetails(orderid, fundunitprice, fundnum);
	}

	@Override
	public void updateOrderDetails2(String orderid, BigDecimal fundunitprice, BigDecimal orderamount,
			BigDecimal handingfee) {
		// TODO Auto-generated method stub
		orderDetailsMapper.updateOrderDetails2(orderid, fundunitprice, orderamount, handingfee);
		
	}


	

}
